package com.oromwin.repos.socket.response.media;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import org.apache.commons.logging.Log;

import com.oromwin.repos.common.Logger;
import com.oromwin.repos.common.ReposException;
import com.oromwin.repos.common.Common.ReposResult;
import com.oromwin.repos.common.helper.IOHelper;
import com.oromwin.repos.socket.response.AbstractResponse;
import com.oromwin.repos.socket.response.volume.CreateVolumeResponse;

public class CreateMediaResponse extends AbstractResponse {
    private Log log = Logger.getLog(CreateVolumeResponse.class);

    public CreateMediaResponse() {
    }
    
    public CreateMediaResponse(ReposResult result, String description) {
        Result = result;
        Description = description;
    }
    
    @Override
    public void receive(DataInputStream dis) throws ReposException {
        try {
            Result = ReposResult.valueOf(IOHelper.readUTF8(dis));
            Description = dis.readUTF();
        } catch (IOException e) {
            throw ReposException.create(log, e);
        }
    }

    @Override
    public void send(DataOutputStream dos) throws ReposException {
        try {
            IOHelper.writeUTF8(dos, Result.toString());
            IOHelper.writeUTF8(dos, Description.toString());
        } catch (IOException e) {
            throw ReposException.create(log, e);
        }
    }

}
